package cn.edu.scau.cmi.zhangjunming.composite.consisentPersion;

import java.util.Set;

public class ConsistentLeaf extends ConsistentComponent{

	private String name;
	
	public ConsistentLeaf(){
		type = 1;
	}
	
	@Override
	public String doSomething() {
		return "你好，我是一致型组合模式中的原子节点，不能包含子节点了。";
	}

	@Override
	public ConsistentComponent getParent() {
		
		return parent;
	}

	@Override
	public ConsistentComponent addChild(ConsistentComponent child) {
		System.out.println("对不起，该节点是叶节点，不能添加子节点");
		return this;
	}

	@Override
	public Set<ConsistentComponent> getChild() {
		System.out.println("该节点是叶节点，没有子节点");
		return null;
	}
	
	public void setName(String s) {
		name = s;
	}
	
	public String getName() {
		return name;
	}

	@Override
	public void setParent(ConsistentComponent parent) {
		this.parent = parent;
	}

	@Override
	public ConsistentComponent deliete(ConsistentComponent child) {
		children.remove(child);
		return this;
	}

	public int getType() {
		return type;
	}
	
	@Override
	public void setType() {
		type = 1;
	}

}
